package com.cjy.hd13;

import java.sql.*;


public class JbdcTest {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        Class.forName("com.mysql.cj.jdbc.Driver");

        Connection conn = DriverManager.getConnection("jdbc:mysql://192.168.65.3:3306/mysql?serverTimezone=UTC&useSSL=false","root","Aa123-456");

        Statement statement = conn.createStatement();

        String sql = "select Host, User from user";

        ResultSet resultSet = statement.executeQuery(sql);

        while (resultSet.next()){
            String host = resultSet.getString("Host");
            String user = resultSet.getString("User");
            System.out.println("Host = "+host+" User = "+user);
        }
        resultSet.close();
        conn.close();
    }
}
